package com.devicemantra.coordinate.ds.tests;
import com.devicemantra.coordinate.dataobjects.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import javax.jdo.PersistenceManager;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.*;

import com.devicemantra.coordinate.dataobjects.CDepartmentFactory;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

@SuppressWarnings("serial")
public class ProcessMessage extends HttpServlet 
{
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException 
	{
		System.out.println("/ProcessMessage called now ");
		String lMessage = req.getParameter("cmessage");
		String lCFrameId = req.getParameter("cframe_id");
		
		
		System.out.println("MESSAGE IS " + lMessage);
		System.out.println("FRAME id is " + lCFrameId);
		
		CMessage1 lMessObj = new CMessage1();
		lMessObj.setDate(new Date());
		lMessObj.setLocationId(lCFrameId);
		lMessObj.setMessage(lMessage);
		//lMessObj.markAsRead();
		
		PersistenceManager pm = PMF.get().getPersistenceManager();
		pm.makePersistent(lMessObj);
		pm.close();
		
		
	}
}
